<style scoped>
    html,body,.layout {height: 100%;}
    .layout{
        border: 1px solid #d7dde4;
        background: #f5f7f9;
        position: relative;
        border-radius: 4px;
        overflow: hidden;
    }
    .layout-breadcrumb{
        padding: 10px 15px 0;
    }
    .layout-content{
        min-height: 200px;
        margin: 15px;
        overflow: hidden;
        background: #fff;
        border-radius: 4px;
    }
    .layout-content-main{
        padding: 10px;
    }
    .layout-copy{
        text-align: center;
        padding: 10px 0 20px;
        color: #9ea7b4;
    }
    .layout-menu-left{
        background: #464c5b;
    }
    .layout-header{
        height: 60px;
        background: #fff;
        box-shadow: 0 1px 1px rgba(0,0,0,.1);
    }
    .layout-logo-left{
        width: 90%;
        height: 40px;
        background: #5b6270;
        border-radius: 3px;
        margin: 15px auto;
    }
    .layout-ceiling-main a{
        color: #9ba7b5;
    }
    .layout-hide-text .layout-text{
        display: none;
    }
    .ivu-col{
        transition: width .2s ease-in-out;
    }
</style>
<template>
    <div id="layout" class="layout" :class="{'layout-hide-text': spanLeft < 4}" :style="{ height: fullHeight+'px' }">
        <Row type="flex" style="height: 100%">
            <Col :span="spanLeft" class="layout-menu-left">
                <Menu active-name="1" theme="dark" width="auto" @on-select="change">
                    <div class="layout-logo-left">
                      
                    </div>
                    <MenuItem name="VechileRoute">
                        <Icon type="ios-navigate" :size="iconSize"></Icon>
                        <span class="layout-text">轨迹分析</span>
                    </MenuItem>
                    <MenuItem name="Frequency">
                        <Icon type="ios-keypad" :size="iconSize"></Icon>
                        <span class="layout-text">频次分析</span>
                    </MenuItem>
                    <MenuItem name="InspectDeploy">
                        <Icon type="ios-analytics" :size="iconSize"></Icon>
                        <span class="layout-text">缉查布控</span>
                    </MenuItem>
                </Menu>
            </Col>
            <Col :span="spanRight">
                <div class="layout-header">
                    <Button type="text" @click="toggleClick">
                        <Icon type="navicon" size="32"></Icon>
                    </Button>
                </div>
                <div class="layout-breadcrumb">
                    <Breadcrumb>
                        <BreadcrumbItem href="#">首页</BreadcrumbItem>
                        <BreadcrumbItem>轨迹分析</BreadcrumbItem>
                    </Breadcrumb>
                </div>
                <div class="layout-content">
                    <div class="layout-content-main">
                      <router-view/>
                    </div>
                </div>
                <div class="layout-copy">
                    2017 &copy; 大数据平台
                </div>
            </Col>
        </Row>
    </div>
</template>
<script>
    export default {
      name: 'app',
        data () {
            console.log(document.body.clientHeight)
            return {
                spanLeft: 4,
                spanRight: 20,
                fullHeight: document.documentElement.clientHeight
            }
        },
        mounted(){
            document.getElementById('layout').style.height=this.fullHeight+"px";//页面初始化
            window.onresize = () => {
                return (() => {
                    this.fullHeight = document.body.clientHeight
                })()
            }
        },
        watch:{
            fullHeight (val) {
                this.fullHeight = val
                document.getElementById('layout').style.height=this.fullHeight-60+"px";//检测窗口的大小，并赋值
            }
        },
        computed: {
            iconSize () {
                return this.spanLeft === 4 ? 14 : 24;
            }
        },
        methods: {
            toggleClick () {
                if (this.spanLeft === 4) {
                    this.spanLeft = 2;
                    this.spanRight = 22;
                } else {
                    this.spanLeft = 4;
                    this.spanRight = 20;
                }
            },
            change(index) {
                console.log(index)
                switch (index){
                    case "VechileRoute":{
                        this.$router.push('/history')
                        break
                    }
                    case "Frequency":{
                        this.$router.push('/frequency')
                        break
                    }
                    case "InspectDeploy":{
                        this.$router.push('/inspectDeploy')
                        break
                    }
                }
            }
        }
    }
</script>
